#include "stdafx.h"
#include "NtLog.h"

#if (NO_NTSHIIPING)

NtLog g_NtLog;

NtLog::NtLog(void)
{
}

NtLog::~NtLog(void)
{
}

void NtLog::OutputLog( const char* szLogFormat, ... )
{
	va_list vl;   

	static char buffer[2048];
	va_start(vl, szLogFormat);
	vsprintf_s(buffer, 2048, szLogFormat, vl);
	va_end(vl);

	printf(buffer);
	printf("\n");
}

NtLog& NtLog::GetInstance()
{
	return g_NtLog;
}

void NtLog::OutputLastError()
{
	DWORD dwError = GetLastError();

	if (dwError == 0)
	{
		return;
	}

	LPTSTR lpMsgBuf = NULL;
	FormatMessage(
		FORMAT_MESSAGE_ALLOCATE_BUFFER |
		FORMAT_MESSAGE_FROM_SYSTEM |
		FORMAT_MESSAGE_IGNORE_INSERTS,
		NULL,
		dwError,
		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
		(LPTSTR) &lpMsgBuf,
		0,
		NULL
		);

	OutputLog(lpMsgBuf);

	LocalFree(lpMsgBuf);
}

#endif

